* File to import user data from Lumosity

***inputs:
* $GameOrigData/la_nauze_user_data_anon_gameid`g'.csv for g  in 55 74 76 77 78 84 104

***outputs:
* $Data/UserData.dta
* $Data/UserZips.dta

* import raw data 

	foreach g  in 55 74 76 77 78 84 104 {
	clear
insheet using $OrigData/la_nauze_user_data_anon_gameid`g'.csv

	gen gamenum = `g' // each game has user data - sometimes different zips (looks like last digit is dropped sometimes)
	
	
save $Data/GameUser`g'.dta, replace
	}
	
use $Data/GameUser55.dta, clear
	
	foreach g  in 74 76 77 78 84 104 {
	
	append using $Data/GameUser`g'.dta
	
erase $Data/GameUser`g'.dta
	}
	
	erase $Data/GameUser55.dta
	
	
	
	
	
* create binary variable for gender 
	gen male = gender=="m"

	drop gender

* define value labels and label values
	label define educvals 1 "Some high school" 2 "High school" 3 "Some college" 4 "Bachelor" ///
	5 "Professional degree" 6 "Masters" 7 "Phd" 8 "Associate" 99 "Other/unspecified"

	label values education_level educvals

* rename and label variables
	rename age age_signup
	label variable age "Age at signup"

	
save $Data/UserData.dta, replace




use $Data/UserData.dta, clear
	
	keep zip 
	
	duplicates drop 
	
save $Data/UserZips.dta, replace 
